package epoch.game.core.buffer;

/**
 * buffer接口
 * 
 * @author will
 *
 */
public interface IBuffer {

	byte readByte();

	short readShort();

	char readChar();

	int readInt();

	long readLong();

	float readFloat();

	double readDouble();

	void readBytes(byte[] bytes);

	byte[] array();

	byte[] readableArray();

	IBuffer writeByte(byte b);

	IBuffer writeShort(short s);

	IBuffer writeChar(char c);

	IBuffer writeInt(int i);

	IBuffer writeLong(long l);

	IBuffer writeFloat(float f);

	IBuffer writeDouble(double d);

	IBuffer writeBytes(byte[] bytes);

	IBuffer writeBytes(byte[] bytes, int offset, int len);

	int readableBytes();

	int writableBytes();

	int readIndex();

	int writeIndex();

	static IBuffer alloc(int buffSize) {
		return BufferAllocator.buffer(buffSize);
	}

	static IBuffer wrap(byte[] bytes) {
		IBuffer buffer = BufferAllocator.buffer(bytes.length);
		buffer.writeBytes(bytes);
		return buffer;
	}

	void flip();

	void setAutoExpand(boolean autoExpand);

}
